import { user } from '../server/user';

import { getUserIcon } from './file';


export async function getUserInfo(self) {
	user.getUserInfo().then(async (res) => {
        if (res.success) {
            self.username = res.data.username;
            self.userIcon = await getUserIcon(res.data.userIcon);
			self.college = res.data.college;
			self.major = res.data.major;
			self.level = res.data.level;
			self.bio = res.data.bio;
        } else {
            uni.showToast({
                title: res.msg,
                icon: 'none'
            });
        }
    }).catch((err) => {
        console.log(err);
        uni.showToast({
			icon: 'none',
			title: '请检查网络',
			duration: 500
		});
    });
}